package sprintServer.start;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import sprintServer.dbconnect.Conn;

public class SerchFriend {
	StringBuffer sql = new StringBuffer();
	Connection con ;
	PreparedStatement pstmt;
	ResultSet rs;
	
	public String serchFriend(String id){
		String result="";
		sql.append("select id from member ");
		sql.append("where id = ?");
		try{
			con = Conn.getConnection();
			pstmt = con.prepareStatement(sql.toString());
			pstmt.setString(1, id);
			rs = pstmt.executeQuery();
			while(rs.next()){
				 String resultid = rs.getString("id");
				 System.out.println("친구 조회 결과"+resultid);
				if(resultid == null){
					result = ":false";
				}else{
					result += ":"+resultid;
				}
			}
			
		}catch(SQLException se){
			System.out.println("에러 :"+se.toString());
		}
		finally{
			try{if(rs != null)rs.close();}catch	(SQLException se1){}
			try{if(pstmt != null)pstmt.close();}catch	(SQLException se1){}
			try{if(con != null)con.close();}catch	(SQLException se1){}			
		}
		return result;
		
	}
}
